using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace Workflows.Components
{
    public delegate void WorkflowMetaDataChanged(WorkflowMetaData metaData);

    [Serializable]
    public class WorkflowMetaData 
    {
        public event WorkflowMetaDataChanged WorkflowMetaDataChangedEvent;

        #region fields
        private Guid _WorkflowGuid;
        private string _WorkflowName;
        private Version _Version;
        private DateTime _CreationTime;
        private DateTime _ModificationTime;
        private string _Author;
        private string _Description;
        private string _FailureNotifyEmailAddress;
        #endregion

        #region ctor
        public WorkflowMetaData()
        {
            this._Author = Environment.UserName;
            this._CreationTime = DateTime.Now;
            this._ModificationTime = DateTime.Now;
            this._Description = "workflow description";
            this._FailureNotifyEmailAddress = Environment.UserName + "@" + Environment.UserDomainName + ".com";
            this._Version = new Version(1, 0);
            this._WorkflowGuid = Guid.NewGuid();
            this._WorkflowName = "New Workflow";
        }
        #endregion

        #region props
        [Browsable(true), Category("Info")]
        public Guid WorkflowGuid
        {
            get
            {
                return this._WorkflowGuid;
            }
            set
            {
                this._WorkflowGuid = value;
                if (this.WorkflowMetaDataChangedEvent != null)
                    this.WorkflowMetaDataChangedEvent(this);
            }
        }
        [Browsable(true), Category("Info")]
        public DateTime CreationTime
        {
            get
            {
                return this._CreationTime;
            }
            set
            {
                this._CreationTime = value;
                if (this.WorkflowMetaDataChangedEvent != null)
                    this.WorkflowMetaDataChangedEvent(this);
            }
        }
        [Browsable(true), Category("Info")]
        public DateTime ModificationTime
        {
            get
            {
                return this._ModificationTime;
            }
            set
            {
                this._ModificationTime = value;
                if (this.WorkflowMetaDataChangedEvent != null)
                    this.WorkflowMetaDataChangedEvent(this);
            }
        }
        [Browsable(true), Category("Info")]
        public Version Version
        {
            get
            {
                return this._Version;
            }
            set
            {
                this._Version = value;
                if (this.WorkflowMetaDataChangedEvent != null)
                    this.WorkflowMetaDataChangedEvent(this);
            }
        }
        [Browsable(true), Category("Info")]
        public string Author
        {
            get
            {
                return this._Author;
            }
            set
            {
                this._Author = value;
                if (this.WorkflowMetaDataChangedEvent != null)
                    this.WorkflowMetaDataChangedEvent(this);
            }
        }
        [Browsable(true), Category("Info")]
        public string WorkflowName
        {
            get
            {
                return this._WorkflowName;
            }
            set
            {
                this._WorkflowName = value;
                if (this.WorkflowMetaDataChangedEvent != null)
                    this.WorkflowMetaDataChangedEvent(this);
            }
        }
        [Browsable(true), Category("Info")]
        public string Description
        {
            get
            {
                return this._Description;
            }
            set
            {
                this._Description = value;
                if (this.WorkflowMetaDataChangedEvent != null)
                    this.WorkflowMetaDataChangedEvent(this);
            }
        }
        [Browsable(true), Category("Info")]
        public string FailureNotifyEmailAddress
        {
            get
            {
                return this._FailureNotifyEmailAddress;
            }
            set
            {
                this._FailureNotifyEmailAddress = value;
                if (this.WorkflowMetaDataChangedEvent != null)
                    this.WorkflowMetaDataChangedEvent(this);
            }
        }
        #endregion
    }
}
